#include "immediate_action.h"
#include "../node/node.h"

OPEN_JLIB_NS


void RemoveSelf::apply () {
  auto target = (Node*)getTarget();
  target->removeSelf(_cleanup);
}
bool RemoveSelf::init (bool cleanup) {
  _cleanup = cleanup;
}


void SwitchFlags::apply () {
  auto target = (Node*)getTarget();
  if (!_action)
    target->disableInlineFlags(_flags);
  else if (_action > 0)
    target->enableInlineFlags(_flags);
  else
    target->toggleInlineFlags(_flags);
}
bool SwitchFlags::init (u64 flags, s32 action) {
  _flags = flags;
  _action = action;
}


void StepOrder::apply () {
  auto target = (Node*)getTarget();
  target->setStepOrder(_order);
}
bool StepOrder::init (s64 order) {
  _order = order;
}


void DrawOrder::apply () {
  auto target = (Node*)getTarget();
  target->setDrawOrder(_order);
}
bool DrawOrder::init (s64 order) {
  _order = order;
}


void Position::apply () {
  auto target = (Node*)getTarget();
  target->setPosition(_position);
}
bool Position::init (Vec3 position) {
  _position = position;
}


void Rotation::apply () {
  auto target = (Node*)getTarget();
  target->setRotation(_rotation);
}
bool Rotation::init (Vec3 rotation) {
  _rotation = rotation;
}


void Scale::apply () {
  auto target = (Node*)getTarget();
  target->setScale(_scale);
}
bool Scale::init (Vec3 scale) {
  _scale = scale;
}


CLOSE_JLIB_NS
